﻿<window:MetroDPIWindow x:Class="CircuitDiagram.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:cd="clr-namespace:CircuitDiagram"
        xmlns:tb="clr-namespace:Toolbox;assembly=Toolbox"
        xmlns:window="clr-namespace:CircuitDiagram.DPIWindow;assembly=CircuitDiagram.DPIWindow"
        Title="Circuit Diagram" Height="565" Width="800" KeyDown="Window_KeyDown" Icon="Images/Logo32.png" Closing="Window_Closing"
        TitleCaps="False" WindowTransitionsEnabled="False" EnableDWMDropShadow="True">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <cd:MultiResolutionImageToImageSourceConverter x:Key="MultiResolutionImageToImageSourceConverter" />
        </ResourceDictionary>
    </Window.Resources>
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File">
                <MenuItem Command="New" Header="_New" />
                <MenuItem Command="Open" Header="_Open" />
                <MenuItem Header="_Recent Files" Name="mnuRecentItems" Click="mnuRecentItem_Click" />
                <Separator />
                <MenuItem Command="Save" Header="_Save" />
                <MenuItem Header="Save _As" Click="mnuFileSaveAs_Click" />
                <Separator />
                <MenuItem Name="mnuFileImport" Header="_Import" />
                <MenuItem Header="_Export" Click="mnuFileExport_Click" />
                <Separator />
                <MenuItem Header="_Print" Click="mnuFilePrint_Click" />
                <Separator />
                <MenuItem Header="_Document..." Click="mnuFileDocument_Click" />
                <Separator />
                <MenuItem Header="E_xit" Click="mnuFileExit_Click" />
            </MenuItem>
            <MenuItem Header="_Edit">
                <MenuItem Command="Undo" Header="_Undo" />
                <MenuItem Command="Redo" Header="_Redo" />
                <Separator />
                <MenuItem Command="Cut" Header="_Cut" />
                <MenuItem Command="Copy" Header="_Copy" />
                <MenuItem Command="Paste" Header="_Paste" />
                <Separator />
                <MenuItem Header="_Document Size" Click="mnuEditResizeDocument" />
            </MenuItem>
            <MenuItem Header="_Tools">
                <MenuItem Header="_Toolbox" Click="mnuToolsToolbox_Click" />
                <MenuItem Header="_Components" Click="mnuFileComponents_Click" />
                <MenuItem Header="_Options" Click="mnuFileOptions_Click" />
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="_Documentation" Click="mnuHelpDocumentation_Click" />
                <Separator />
                <MenuItem Header="Check for _Updates" Click="mnuCheckForUpdates_Click" />
                <Separator />
                <MenuItem Header="_About" Click="mnuHelpAbout_Click" />
            </MenuItem>
        </Menu>
        <StatusBar DockPanel.Dock="Bottom" Height="23" Style="{StaticResource StatusBarStyle}">
            <TextBlock Name="lblStatus" Text="Ready" />
        </StatusBar>
        <ScrollViewer Style="{StaticResource ToolboxScrollViewer}" DockPanel.Dock="Left" Name="toolboxScroll" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
            <tb:Toolbox x:Name="mainToolbox" DockPanel.Dock="Left" Width="60" Style="{StaticResource ToolboxStyle}"
                        ItemContainerStyle="{StaticResource ToolboxCategoryStyle}" SelectionChanged="mainToolbox_SelectionChanged">
                <tb:Toolbox.CategoryItemTemplate>
                    <DataTemplate>
                        <Rectangle Fill="White" Width="32" Height="32" ToolTip="{Binding DisplayName}">
                            <Rectangle.OpacityMask>
                                <ImageBrush ImageSource="{Binding Path=Icon, Converter={StaticResource MultiResolutionImageToImageSourceConverter}}" Stretch="None" />
                            </Rectangle.OpacityMask>
                        </Rectangle>
                    </DataTemplate>
                </tb:Toolbox.CategoryItemTemplate>
                <tb:Toolbox.CategoryMainItemTemplate>
                    <DataTemplate>
                        <Rectangle Fill="White" Width="32" Height="32" ToolTip="{Binding DisplayName}">
                            <Rectangle.OpacityMask>
                                <ImageBrush ImageSource="{Binding Path=Icon, Converter={StaticResource MultiResolutionImageToImageSourceConverter}}" Stretch="None" />
                            </Rectangle.OpacityMask>
                        </Rectangle>
                    </DataTemplate>
                </tb:Toolbox.CategoryMainItemTemplate>
            </tb:Toolbox>
        </ScrollViewer>
        <Grid DockPanel.Dock="Right" Width="175">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="40" />
            </Grid.RowDefinitions>
            <ScrollViewer Name="gridEditor" Grid.Row="0" VerticalScrollBarVisibility="Auto">

            </ScrollViewer>
            <Grid Grid.Row="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="5" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Rectangle Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Stroke="Gray" StrokeThickness="2" Height="1" Width="160" />
                <Label Grid.Row="1" Grid.Column="0" Content="Zoom" Height="28" Margin="5,0,0,0" Name="lblSliderZoom" MouseDoubleClick="lblSliderZoom_MouseDoubleClick" ToolTip="Double click to reset" />
                <Slider Grid.Row="1" Grid.Column="1" Height="23" Name="sliderZoom" Width="100" Minimum="10" Maximum="90" Value="50" ValueChanged="sliderZoom_ValueChanged" TickPlacement="BottomRight" SmallChange="1" LargeChange="10">
                    <Slider.Ticks>
                        <DoubleCollection>50</DoubleCollection>
                    </Slider.Ticks>
                </Slider>
            </Grid>
        </Grid>
        <ScrollViewer Background="LightGray" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
            <cd:CircuitDisplay x:Name="circuitDisplay" SelectionChanged="circuitDisplay_SelectionChanged" SnapsToDevicePixels="True" MouseWheel="circuitDisplay_MouseWheel">
                <cd:CircuitDisplay.ContextMenu>
                    <ContextMenu Style="{StaticResource ContextMenuStyle}">
                        <MenuItem Command="cd:CustomCommands.DeleteComponent" Style="{StaticResource ContextMenuItemStyle}" />
                        <MenuItem Command="cd:CustomCommands.FlipComponent" Style="{StaticResource ContextMenuItemStyle}" />
                        <MenuItem Command="cd:CustomCommands.RotateComponent" Style="{StaticResource ContextMenuItemStyle}" />
                    </ContextMenu>
                </cd:CircuitDisplay.ContextMenu>
            </cd:CircuitDisplay>
        </ScrollViewer>
    </DockPanel>
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.New" CanExecute="CommandNew_CanExecute" Executed="CommandNew_Executed" />
        <CommandBinding Command="ApplicationCommands.Open"  CanExecute="CommandOpen_CanExecute" Executed="CommandOpen_Executed" />
        <CommandBinding Command="ApplicationCommands.Save"  CanExecute="CommandSave_CanExecute" Executed="CommandSave_Executed" />
        <CommandBinding Command="Undo" CanExecute="CommandUndo_CanExecute" Executed="CommandUndo_Executed" />
        <CommandBinding Command="Redo" CanExecute="CommandRedo_CanExecute" Executed="CommandRedo_Executed" />
        <CommandBinding Command="Cut" CanExecute="CommandCut_CanExecute" Executed="CommandCut_Executed" />
        <CommandBinding Command="Copy" CanExecute="CommandCopy_CanExecute" Executed="CommandCopy_Executed" />
        <CommandBinding Command="Paste" CanExecute="CommandPaste_CanExecute" Executed="CommandPaste_Executed" />
        <CommandBinding Command="cd:CustomCommands.DeleteComponent" CanExecute="DeleteComponentCommand_CanExecute" Executed="DeleteComponentCommand_Executed" />
        <CommandBinding Command="cd:CustomCommands.FlipComponent" CanExecute="FlipComponentCommand_CanExecute" Executed="FlipComponentCommand_Executed" />
        <CommandBinding Command="cd:CustomCommands.RotateComponent" CanExecute="RotateComponentCommand_CanExecute" Executed="RotateComponentCommand_Executed" />
    </Window.CommandBindings>
</window:MetroDPIWindow>
